package com.dongdong.bookstore.module.ums.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dongdong.bookstore.module.ums.model.Admin;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dongdong.bookstore.module.ums.model.Role;
import com.dongdong.bookstore.module.ums.viewmodel.AdminRegistParam;
import com.dongdong.bookstore.module.ums.viewmodel.AdminWithLastLoginTime;
import com.dongdong.bookstore.module.ums.viewmodel.UpdateAdminPasswordParam;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.List;

/**
 * <p>
 * 管理员表 服务类
 * </p>
 *
 * @author chiangkai
 * @since 2021-10-20
 */
public interface AdminService extends IService<Admin> {

    Admin register(AdminRegistParam param);

    Long registerGetId(AdminRegistParam param);

    String login(String username, String password);

    void judgeAdminExist(String username);

    Admin getAdminByUsername(String username);

    /**
     * 获取用户通过用户名
     */
    UserDetails loadUserByName(String username);

    /**
     * 刷新token
     */
    String refreshToken(String token);

    /**
     * 获取用户列表
     * @return
     */
    IPage<AdminWithLastLoginTime> list(String keyword, Integer pageSize, Integer pageNum);

    /**
     * 更新管理员用户信息
     */
    boolean update(Long id, Admin admin);

    /**
     * 通过旧密码更新密码
     */
    void updatePassword(UpdateAdminPasswordParam updateAdminPasswordParam);

    List<Role> getRoleList(Long adminId);


    boolean delete(Long id,String username);
}
